package com.shycloud.mido.music.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shycloud.mido.common.security.util.SecurityUtils;
import com.shycloud.mido.music.domain.MisUserCollection;
import com.shycloud.mido.music.mapper.MisUserCollectionMapper;
import com.shycloud.mido.music.service.MisUserCollectionService;
import com.shycloud.mido.music.vo.CollCourseWareVO;
import com.shycloud.mido.music.vo.MyCollectionVO;
import com.shycloud.mido.music.vo.UserCollectionVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class MisUserCollectionServiceImpl extends ServiceImpl<MisUserCollectionMapper, MisUserCollection> implements MisUserCollectionService {

	/** 收藏曲集模块 mapper */
	private MisUserCollectionMapper userCollectionMapper;

	/**
	 * 分页获取我收藏的曲集信息
	 *
	 * @param memberId
	 * @param page
	 * @return com.baomidou.mybatisplus.core.metadata.IPage
	 * @author nianhua.jiang
	 * @date 2020/6/16 15:28
	 */
	@Override
	public IPage<UserCollectionVO> getUserCollection(String memberId, Page page) {
		return userCollectionMapper.getUserCollection(page, memberId);
	}

	/**
	 * 分页获取定制曲集列表
	 *
	 * @param memberId
	 * @param page
	 * @return com.baomidou.mybatisplus.core.metadata.IPage<com.shycloud.mido.music.vo.UserCollectionVO>
	 * @author nianhua.jiang
	 * @date 2020/7/6 16:53
	 */
	@Override
	public IPage<UserCollectionVO> getUserCollectionIsCustom(String memberId, Page page) {
		return userCollectionMapper.getUserCollectionIsCustom(page, memberId);
	}

	@Override
	public Integer getCount(String memberId) {
		return userCollectionMapper.getCount(memberId);
	}

	@Override
	public List<MyCollectionVO> getUserCollectionByMini(String searchWord, String memberId) {
		return userCollectionMapper.getUserCollectionByMini(searchWord, memberId);
	}

	@Override
	public List<CollCourseWareVO> getCoursewareFolderList(Integer groupId) {

		if (groupId == -1) {
			return userCollectionMapper.getFolderListAll(SecurityUtils.getMember().getId());
		}

		return userCollectionMapper.getFolderList(groupId);
	}
}
